package com.chj.Interceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import com.chj.constants.Constants;

public class ECarChargeInterceptor extends HandlerInterceptorAdapter {

    @Override
    public boolean preHandle(HttpServletRequest  request
                           , HttpServletResponse response
                           , Object handler) throws Exception {

        HttpSession session = request.getSession();
        Object loginAmdin = session.getAttribute(Constants.LOGIN_USER);

        if (loginAmdin == null) {

            response.sendRedirect(request.getContextPath() +"/user/login.do");
            return false;
        }

        return true;
    }

}
